import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class addAgent extends HttpServlet
{
	public static dbapi conn;
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException
	{
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		conn = new dbapi();
		conn.connect();
		if(conn.connected)
			out.println("connected via dbapi <br>");
		else
		{
			out.println("CANT CONNECT! <br>");
			out.println(conn.msg + "<br>");
			return;
		}
		String agentName = request.getParameter("AGENTNAME");
		boolean worked = conn.addAgent(agentName);
		if (!worked)
		{
			out.println(conn.msg);
		}else{
			out.println("worked.");
		}
		return;
	}
}
